package yxy.game.pm2.command.chibi;

import yxy.cherry.game.base.message.MessageEmitterHandler;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.game.pm2.Result;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.ChibiMessage;
import yxy.game.pm2.module.chibi.ChibiHandle;

/** 火烧赤壁 火烧赤壁扫荡 */
@MessageType(proto = Command.ChibiSweep, classtype = ChibiMessage.ChibiSweepRequest.class)
public class CMD_ChibiSweep extends Command<ChibiMessage.ChibiSweepRequest> {

	@Override
	public void execute(MessageSource messageSource, ChibiMessage.ChibiSweepRequest request) {
		String playerCode = messageSource.getTag();
		int id = request.getId();

		ChibiMessage.ChibiSweepResponse.Builder response = ChibiMessage.ChibiSweepResponse.newBuilder();

		Result result = new ChibiHandle().sweep(playerCode, id, response);

		send(messageSource, response, result);
	}

	private void send(MessageSource messageSource, ChibiMessage.ChibiSweepResponse.Builder response, Result result) {
		response.setResult(result.packResult());
		MessageEmitterHandler.getInstance().send(messageSource, response.build());
	}
}